﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using ZF.BLL;
using System.Linq.Expressions;
using GCELibrary.Current;
using ZF.BLL.Linq;
namespace ZF.WS.house
{
    public partial class Search:BLL.Page.PageBase
    {
        [PageArgument(Key = "aid", DefaultValue=-1)]
        public int AreaId { get; set; }
        [PageArgument(Key = "aid2", DefaultValue = -1)]
        public int AreaId2 { get; set; }
        [PageArgument(Key = "ht", DefaultValue = null)]
        public string HT { get; set; }
        [PageArgument(Key = "dt", DefaultValue = -1)]
        public int DT { get; set; }

        [PageArgument(Key = "p", DefaultValue = null)]
        public string Price { get; set; }
        [PageArgument(Key = "tin", DefaultValue = -1)]
        public int Tin { get; set; }
        [PageArgument(Key = "fan", DefaultValue = -1)]
        public int Fan { get; set; }

        public List<Model.Dic_Area> GDCity
        {

            get
            {
                return BLL.DictionaryConfig.HArea.Where(p => p.ParentId == 0 && p.Name != "广州市").ToList();
            }
        }
        public List<Model.Dic_Area> GZCity
        {

            get
            {
               
                var gz = BLL.DictionaryConfig.HArea.FirstOrDefault(p => p.Name == "广州市");

                return BLL.DictionaryConfig.HArea.Where(p => p.ParentId == gz.AreaId).ToList();
            }
        }
        public List<Model.Dic_Area> City
        {
            get
            {

                var list = GZCity;
                list.AddRange(GDCity);
                return list;
            }
        }
        public List<SimpleTree<int>> AreaChilds
        {
            get
            {
                var citys = City.Select(p =>
                    new SimpleTree<int>
                    {
                        Childs = new List<SimpleTree<int>>(),
                        Id = p.AreaId,
                        ParentId = p.ParentId,
                        Name = p.Name

                    }).ToList();
                var areas = BLL.DictionaryConfig.HArea.Select(p =>
                    new SimpleTree<int>
                    {
                        Childs = new List<SimpleTree<int>>(),
                        Id = p.AreaId,
                        ParentId = p.ParentId,
                        Name = p.Name

                    }).ToList();

                areas.ForEach(p =>
                {
                    var city = citys.FirstOrDefault(c => c.Id == p.ParentId);
                    if (city != null)
                        city.Childs.Add(p);
                });

                return citys;
            }
        }
        public List<Keyword<string>> HouseType { get { return BLL.DictionaryConfig.HHouseType; } }
        
       
        public Model.Dic_Area SelArea { get; set; }
        public Keyword<string> SelHouseType { get; set; }
        public int SelDealType { get; set; }
        public string[][] ZFPrice
        {
            get
            {
                return new string[][]
            {
              
                new string[]{"300以下","","300"},
                new string[]{"500以下","","500"},
                new string[]{"500-1000","500","1000"},
                new string[]{"1000-1500","1000","1500"},
                new string[]{"1500-2000","1500","2000"},
                new string[]{"2000-2500","2000","2500"},
                new string[]{"2500-3000","2500","3000"},
                new string[]{"3000以上","3000",""},
            
            };
            }
        }//租房价格
        public string[][] SfPrice
        {
            get
            {
                return     new string[][]//售房价格
            {
           
                new string[]{"10万以下","","10"},
                new string[]{"10-20万","10","20"},
                new string[]{"20-30万","20","30"},
                new string[]{"30-40万","30","40"},
                new string[]{"40-50万","40","50"},
                new string[]{"50-100万","50","100"},
                new string[]{"100-200万","100","200"},
                new string[]{"200-500万","200","500"},
                new string[]{"500万以上 ","500",""},
            
            };
            }
        }//售房价格

        public string[] SelZFPrice { get; set; }
        public string[] SelSFPrice { get; set; }
        public void Page_Load(object sender, EventArgs e)
        {

 

            if (AreaId != -1)
                this.SelArea = City.FirstOrDefault(p => p.AreaId == this.AreaId);
            if (HT != null)
                this.SelHouseType = HouseType.FirstOrDefault(p => p.Key == this.HT);
            if (DT >= 1 && DT <= 4)
                this.SelDealType = this.DT;
        }
 
    }
 
}
